let host=window.location.host;
let index=0;
let len=0;
function search() {

    //remove advertisement
    $("#content_left").children("div").css("display","none");
    $("#content_left").attr("id","content");
    //css
    $("#content_right").remove();
    $("#content").css("margin-left","50px");
    $("#content").css("width",$("#wrapper_wrapper").width());
   // $(".c-container").css("float","left");
    $(".c-container").css("display","block");
    $(".c-container").css("margin","20px");
    $(".c-container").css("padding","10px");
    $(".c-container").css("background","#eeeeee");
    $(".c-container").css("border-radius","6px");
    len=$(".c-container").length;
   let sw=$(".c-container")[index];
    $(sw).css("background","gray");
    //default chose
    $(".c-container")
    const KEY_UP=38;
    const KEY_DOWN=40;
    const KEY_LEFT=37;
    const KEY_RIGHT=39;
    const KEY_ENTER=13;
    $(document).keydown((e)=>{
        var key =  e.which;
        if(key==KEY_DOWN ){
         let sw=$(".c-container")[index];
         $(sw).css("background","#eeeeee");
            let h=$(document).scrollTop();
            let h1=$(sw).height();
            $(document).scrollTop(h+h1);
        index=(index+1)%len;
        console.log(index)
        sw=$(".c-container")[index];
         $(sw).css("background","gray");

        }
        if(key==KEY_UP){
            let sw=$(".c-container")[index];
            $(sw).css("background","#eeeeee");
            let h=$(document).scrollTop();
            let h1=$(sw).height();
            $(document).scrollTop(h-h1);
            index=index-1;
            if(index==-1)
                index=len+index;
            sw=$(".c-container")[index];
            $(sw).css("background","gray");

        }
        if(key==KEY_ENTER){
            let sw=$(".c-container")[index];
            $(sw).find(".t").find("a").attr("id",`a_${index}`);
            document.getElementById(`a_${index}`).click();
        }
    })

}

if(host=="www.baidu.com"){
search();

}